package com.starlink.client.jd.request;

import com.lop.open.api.sdk.domain.ECAP.CommonModifyCancelOrderApi.commonModifyOrderV1.CommonModifyCancelOrderRequest;
import com.starlink.client.jd.request.base.Contact;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 修改订单入参模型
 * 传参规则详情见京东文档
 * <a href="https://open.jdl.com/#/open-business-document/api-doc/267/845"/>
 */
@Data
@NoArgsConstructor
public class ModifyOrderRequest implements Serializable {
    /**
     * 商家订单号，与下单接口入参保持一致；字段长度1-50
     */
    private String orderId;
    /**
     * 京东物流运单号，运单号在下单接口中已返回，同订单号必填其一
     */
    private String waybillCode;
    /**
     * 京东物流订单号，订单号在下单接口中已返回，与京东运单号必填其一
     */
    private String orderCode;
    /**
     * 寄件人信息
     */
    private Contact senderContact;
    /**
     * 收件人信息
     */
    private Contact receiverContact;
    /**
     * 下单来源 0-c2c 1-b2c 2-c2b；与下单接口的入参保持一致
     */
    private Integer orderOrigin;
    /**
     * 客户编码；orderOrigin=1或orderOrigin=2时必填；与下单接口的入参保持一致，长度1-32
     */
    private String customerCode;

    /**
     * 模型转换
     * @return
     */
    public CommonModifyCancelOrderRequest toJd4Modify() {
        CommonModifyCancelOrderRequest request = new CommonModifyCancelOrderRequest();
        request.setOrderId(this.orderId);
        request.setWaybillCode(this.waybillCode);
        request.setOrderCode(this.orderCode);
        request.setSenderContact(this.senderContact.toJdModify());
        request.setReceiverContact(this.receiverContact.toJdModify());
        request.setOrderOrigin(1);
        request.setCustomerCode(this.customerCode);
        return request;
    }
}
